<template>
  <div class="app-container">
    <!-- 查询 -->
    <tl-list-search ref="search" :query-param="queryParam" @search="doQuery" :isDisplayDefaultSearch="false" :isDisplaySearch="false" v-if="isHeaderDisplay">
      <template slot="search">
        <el-form-item label="对接系统">
          <el-input v-model="queryParam.qry_projectName" :disabled="true" class="tl-ref-selector" style="width:150px">
            <el-button slot="append" type="primary" icon="el-icon-search" @click="openSysAppRefDialog"></el-button>
          </el-input>
        </el-form-item>
        <el-form-item label="调用日期" prop="queryParam.qry_createon">
          <el-date-picker v-model="queryParam.qry_createon" type="date" placeholder="调用日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd"></el-date-picker>
        </el-form-item>
        <el-form-item label="单据编号">
          <el-input v-model="queryParam.qry_sourceid" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="接口地址">
          <el-input v-model="queryParam.qry_url" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="Post参数">
          <el-input v-model="queryParam.qry_postparam" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="单据类型">
          <el-select v-model="queryParam.qry_sourcetype" clearable>
            <el-option v-for="item in codeModel.sourcetypeList" :key="item.code" :label="item.name" :value="item.code" clearable />
          </el-select>
        </el-form-item>
        <el-form-item label="调用类型">
          <el-select v-model="queryParam.qry_calltype" clearable>
            <el-option v-for="item in codeModel.calltypeList" :key="item.code" :label="item.name" :value="item.code" clearable />
          </el-select>
        </el-form-item>
        <el-form-item label="状态码">
          <el-input v-model="queryParam.qry_statuscode" placeholder=""></el-input>
        </el-form-item>
        <el-button class="filter-item" type="primary" icon="el-icon-search" @click="doQuery">搜索</el-button>
        <el-button class="filter-item" type="primary" icon="el-icon-refresh-right" @click="resetQueryParam">重置</el-button>
      </template>
    </tl-list-search>
    <!-- 工具栏 -->
    <tl-list-toolbar ref="toolbar" @add="openAddDialog('editForm')" :isDisplayAdd="false" @exportExcel="doExportExcel" @deleteBatch="doDeleteBatch" @refresh="doRefresh" @columnCustomize="doColumnCustomize" @displaySearch="doDisplaySearch" :disableDeleteBatch="selectedRowKeys.length <= 0">
      <template slot="left-btn"> </template>
    </tl-list-toolbar>
    <div>
      <!-- 列表选择 -->
      <div class="table-alert-div" ref="selector">
        <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
          <template slot="title">
            已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRowKeys.length }}</a
            >项&nbsp;&nbsp;
            <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
          </template>
        </el-alert>
      </div>
      <!--表格渲染-->
      <el-table class="tl-table" ref="mainTable" :height="tableHeight" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
        <el-table-column type="selection" width="55px" fixed="left"></el-table-column>
        <el-table-column prop="project" label="对接系统" width="150px" sortable="custom" sort-by="project" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispcalltype" label="调用类型" width="100px" sortable="custom" sort-by="calltype" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispsourcetype" label="单据类型" width="150px" sortable="custom" sort-by="sourcetype" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="sourceid" label="单据编号" width="150px" sortable="custom" sort-by="sourceid" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="url" label="接口地址" width="150px" sortable="custom" sort-by="url" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="postparam" label="Post参数" min-width="150px" sortable="custom" sort-by="postparam" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="statuscode" label="返回状态码" width="120px" sortable="custom" sort-by="statuscode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="responsemsg" label="返回值" width="150px" sortable="custom" sort-by="responsemsg" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="createon" label="调用时间" width="170px" sortable="custom" sort-by="createon" align="center" header-align="center" :formatter="dateTimeFormat" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="操作" width="100px" v-slot="scope" fixed="right">
          <el-dropdown trigger="hover">
            <el-button type="text" icon="el-icon-s-operation" style="margin-left:10px">更多<i class="el-icon-arrow-down el-icon--right"></i></el-button>
            <el-dropdown-menu>
              <el-dropdown-item icon="el-icon-view" @click.native="openViewDialog('editForm', scope.row.id)">查看</el-dropdown-item>
              <el-dropdown-item icon="el-icon-edit" @click.native="openEditDialog('editForm', scope.row.id)">编辑</el-dropdown-item>
              <el-dropdown-item icon="el-icon-delete" @click.native="doDelete(scope.row.id)">删除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" ref="pager">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
      </el-row>
      <tl-sys-app-ref ref="sysAppRef" @confirm="getSysAppRefData" :isSingleSelect="true"></tl-sys-app-ref>
      <tl-edit ref="editForm" @refresh="doRefresh"></tl-edit>
    </div>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import tlEdit from './edit'
import tlSysAppRef from '@/views/sys/sysApp/refList'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
export default {
  name: 'sysApiLog',
  mixins: [mixin_list],
  components: { tlEdit, tlSysAppRef },
  data() {
    return {
      description: '接口传输日志-列表查询',
      urlPrefix: '/sys/apiLog/',
      url: {
        queryCodeList: '/sys/apiLog/dataCodeList'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'createon',
        sord: 'desc'
      }
    }
  },
  methods: {
    /** 打开对接系统参照 */
    openSysAppRefDialog() {
      this.$refs.sysAppRef.visible = true
    },
    /** 获取对接系统参照数据 */
    getSysAppRefData(selectionRow, selectKey, selectionValue) {
      this.$set(this.queryParam, 'qry_project', selectionRow.code)
      this.$set(this.queryParam, 'qry_projectName', selectionRow.name)
    },
    resetQueryParam() {
      this.queryParam = {}
    }
  }
}
</script>

<style scoped></style>
